//子类继承父类后,当创建子类对象,也会调用父类的构造函数
//继承中的构造和析构顺序
#include <iostream>
using namespace std;

class Base1{
public:
    Base1(){
        cout << "Base构造函数" << endl;
    }
    ~Base1(){
        cout << "Base析构函数" << endl;
    }

};

class Son : public Base1{
public:
    Son(){
        cout << "Son构造函数" << endl;
    }
    ~Son(){
        cout << "Son析构函数" << endl;
    }

};

void test01(){
    // Base1 b;
    //继承中的构造和析构的顺序如下:
    //先构造父类,再构造子类,析构的顺序与构造的顺序相反
    Son s;
}


int main(){
    test01();
    system("pause");
    return 0;
}